

package vistas;

import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.table.DefaultTableModel;

import controladores.CCategoria;
import controladores.CListado;
import modelos.MIngrediente;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VListado extends javax.swing.JFrame {
    private controladores.CListado control;
    private DefaultTableModel modeloTabla;
    private Vector<String> fila;
    private CListado lista;
	
    /** Creates new form CListado */
    public VListado(CListado list) {
    	super();
		initComponents();
		lista= list;
        modeloTabla= new DefaultTableModel();
        tblGeneral.setModel(modeloTabla);
        control = list;
        reiniciar();
    }


     public void addListener(ActionListener escuchador){
        rbtMas.addActionListener(escuchador);
        rbtProducto.addActionListener(escuchador);
        btnSalir.addActionListener(escuchador);
        btnCancelar.addActionListener(escuchador);
        rbtnIngrediente.addActionListener(escuchador);
        cckAsc.addActionListener(escuchador);
        cckDesc.addActionListener(escuchador);
        rbtMas.setActionCommand("Mas");
        rbtProducto.setActionCommand("Producto");
        btnSalir.setActionCommand("Salir");
        btnCancelar.setActionCommand("Cancelar");
        rbtnIngrediente.setActionCommand("Ingrediente");
        cckAsc.setActionCommand("Asc");
        cckDesc.setActionCommand("Desc");
    }

    public void ingredientes(){
        setTitle("Listado de Ingredientes");
        fila= new Vector<String>();
        fila.add("Ingrediente");
        fila.add("Stock");
        modeloTabla.setColumnIdentifiers(fila);
    }

    public void productos(){
         lblOrdenado.setVisible(true);
       cckAsc.setVisible(true);
        cckDesc.setVisible(true);
        setTitle("Listado de Productos");
        fila= new Vector<String>();
        fila.add("Producto");
        fila.add("Total Generado");
        fila.add("Cantidad Vendida");
        modeloTabla.setColumnIdentifiers(fila);
    }

    public void mas(){
         lblOrdenado.setVisible(true);
       cckAsc.setVisible(true);
        cckDesc.setVisible(true);
        setTitle("Ingredientes mas Usados");
        fila= new Vector<String>();
        fila.add("Ingrediente");
        fila.add("Cantidades");
        modeloTabla.setColumnIdentifiers(fila);
    }


    public void agregarFila(MIngrediente m){
        fila= new Vector<String>();
        fila.add(m.getDescripcion());
        fila.add(""+m.getStock());
        modeloTabla.addRow(fila);
    }

    public void agregarFila(String[] v){
        modeloTabla.setColumnIdentifiers(fila);
        fila = new Vector<String>();
        for (int i = 0; i < v.length; i++)
            fila.add(v[i]);
        modeloTabla.addRow(fila);
    }

    public void  reiniciar() {
        setTitle("");
        modeloTabla.setRowCount(0);
    }


    



    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblGeneral = new javax.swing.JTable();
        btnCancelar = new javax.swing.JButton();
        btnSalir = new javax.swing.JButton();
        cckAsc = new javax.swing.JCheckBox();
        cckDesc = new javax.swing.JCheckBox();
        rbtnIngrediente = new javax.swing.JRadioButton();
        rbtProducto = new javax.swing.JRadioButton();
        rbtMas = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();
        lblOrdenado = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(null);

        tblGeneral.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tblGeneral);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(10, 140, 720, 340);

        btnCancelar.setFont(new java.awt.Font("Andale Mono", 0, 15));
        btnCancelar.setText("Cancelar");
        getContentPane().add(btnCancelar);
        btnCancelar.setBounds(250, 500, 120, 30);

        btnSalir.setFont(new java.awt.Font("Andale Mono", 0, 15));
        btnSalir.setText("Salir");
        getContentPane().add(btnSalir);
        btnSalir.setBounds(410, 500, 120, 30);

        cckAsc.setFont(new java.awt.Font("Andale Mono", 0, 15));
        cckAsc.setText("Ascendentemente");
        getContentPane().add(cckAsc);
        cckAsc.setBounds(390, 40, 180, 22);
        cckAsc.setBackground(new java.awt.Color(230,238,250));

        cckDesc.setFont(new java.awt.Font("Andale Mono", 0, 15));
        cckDesc.setText("Descendentemente");
        getContentPane().add(cckDesc);
        cckDesc.setBounds(390, 80, 190, 22);
        cckDesc.setBackground(new java.awt.Color(230,238,250));

        buttonGroup1.add(rbtnIngrediente);
        rbtnIngrediente.setFont(new java.awt.Font("Andale Mono", 0, 15));
        rbtnIngrediente.setText("Ingredientes");
        getContentPane().add(rbtnIngrediente);
        rbtnIngrediente.setBounds(60, 40, 210, 22);
        rbtnIngrediente.setBackground(new java.awt.Color(230,238,250));

        buttonGroup1.add(rbtProducto);
        rbtProducto.setFont(new java.awt.Font("Andale Mono", 0, 15));
        rbtProducto.setText("Productos");
        getContentPane().add(rbtProducto);
        rbtProducto.setBounds(60, 70, 200, 22);
        rbtProducto.setBackground(new java.awt.Color(230,238,250));

        buttonGroup1.add(rbtMas);
        rbtMas.setFont(new java.awt.Font("Andale Mono", 0, 15));
        rbtMas.setText("Ingrientes Mas Usados");
        getContentPane().add(rbtMas);
        rbtMas.setBounds(60, 100, 270, 22);
        rbtMas.setBackground(new java.awt.Color(230,238,250));

        jLabel1.setFont(new java.awt.Font("Andale Mono", 1, 15));
        jLabel1.setText("Listados");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(90, 10, 80, 20);

        lblOrdenado.setFont(new java.awt.Font("Andale Mono", 1, 15));
        lblOrdenado.setText("Ordenados");
        getContentPane().add(lblOrdenado);
        lblOrdenado.setBounds(440, 10, 90, 20);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(0, 0, 764, 579);
        getContentPane().setBackground(new java.awt.Color(230,238,250));
    }// </editor-fold>//GEN-END:initComponents

   
  

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnSalir;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JCheckBox cckAsc;
    private javax.swing.JCheckBox cckDesc;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblOrdenado;
    private javax.swing.JRadioButton rbtMas;
    private javax.swing.JRadioButton rbtProducto;
    private javax.swing.JRadioButton rbtnIngrediente;
    private javax.swing.JTable tblGeneral;
    // End of variables declaration//GEN-END:variables

}
